{% extends 'admin/base.html' %}

{% block title %}添加用户 - 管理后台{% endblock %}
{% block page_title %}添加用户{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-8">
        <div class="card">
            <div class="card-header">
                <h5 class="card-title mb-0">
                    <i class="bi bi-person-plus"></i> 添加新用户
                </h5>
            </div>
            <div class="card-body">
                <form method="post">
                    {% csrf_token %}
                    <div class="row">
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="username" class="form-label">用户名 <span class="text-danger">*</span></label>
                                <input type="text" class="form-control" id="username" name="username" required>
                                <div class="form-text">用户名必须唯一，用于登录系统</div>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="password" class="form-label">密码 <span class="text-danger">*</span></label>
                                <input type="password" class="form-control" id="password" name="password" required>
                                <div class="form-text">密码长度至少8位</div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="row">
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label for="college" class="form-label">所属学院 <span class="text-danger">*</span></label>
                                <select class="form-select" id="college" name="college" required>
                                    <option value="">请选择学院</option>
                                    {% for value, label in college_choices %}
                                    <option value="{{ value }}">{{ label }}</option>
                                    {% endfor %}
                                </select>
                            </div>
                        </div>
                        <div class="col-md-6">
                            <div class="mb-3">
                                <label class="form-label">权限设置</label>
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" id="is_admin" name="is_admin">
                                    <label class="form-check-label" for="is_admin">
                                        学院管理员
                                    </label>
                                    <div class="form-text">可以管理本学院的自行车数据</div>
                                </div>
                                <div class="form-check">
                                    <input class="form-check-input" type="checkbox" id="is_super_admin" name="is_super_admin">
                                    <label class="form-check-label" for="is_super_admin">
                                        超级管理员
                                    </label>
                                    <div class="form-text">可以管理所有学院的数据和用户</div>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                    <div class="d-flex justify-content-between">
                        <a href="{% url 'bike:user_management' %}" class="btn btn-outline-secondary">
                            <i class="bi bi-arrow-left"></i> 返回用户列表
                        </a>
                        <button type="submit" class="btn btn-primary">
                            <i class="bi bi-check"></i> 创建用户
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    
    <div class="col-md-4">
        <div class="card">
            <div class="card-header">
                <h6 class="card-title mb-0">
                    <i class="bi bi-info-circle"></i> 说明
                </h6>
            </div>
            <div class="card-body">
                <h6>权限说明：</h6>
                <ul class="list-unstyled">
                    <li><i class="bi bi-circle-fill text-secondary me-2"></i>普通用户：只能查看数据</li>
                    <li><i class="bi bi-circle-fill text-info me-2"></i>学院管理员：管理本学院数据</li>
                    <li><i class="bi bi-circle-fill text-danger me-2"></i>超级管理员：管理所有数据</li>
                </ul>
                
                <h6 class="mt-3">注意事项：</h6>
                <ul class="list-unstyled small text-muted">
                    <li>• 用户名不能重复</li>
                    <li>• 密码建议使用复杂组合</li>
                    <li>• 超级管理员权限请谨慎分配</li>
                </ul>
            </div>
        </div>
    </div>
</div>
{% endblock %}
